package com.park.user.controller.park;

import com.park.controller.BaseController;
import com.park.entity.car.CarLocation;
import com.park.entity.licenseplate.LicenseParkVo;
import com.park.entity.park.ParkInfo;
import com.park.response.Result;
import com.park.user.anno.UserToken;
import com.park.user.service.park.ParkInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Administrator
 * @title: ParkInfoController
 * @projectName park
 * @description: 停车场信息控制器
 * @date 2020/5/221:44
 */
@RestController
@RequestMapping(value = "/wx/park")
public class ParkInfoController extends BaseController {

    @Autowired
    private ParkInfoService parkInfoService;

    /* *
     * @Author zhanghaiwen
     * @Description 查询是否可以停车
     * @Date 14:16 2020/1/8
     * @Param [User]
     * @Version 6.1.1
     * @return
     */
    @UserToken
    @RequestMapping(value = "/canpark",method = RequestMethod.POST)
    public Result canpark(@RequestBody CarLocation carLocation){
        carLocation.setUserId(getUserId());
        LicenseParkVo licenseParkVo = parkInfoService.getCanPark(carLocation);
        return SUCCESS(licenseParkVo);
    }

    /* *
     * @Author zhanghaiwen
     * @Description 停车，提交订单
     * @Date 14:16 2020/1/8
     * @Param [User]
     * @Version 6.1.1
     * @return
     */
    @UserToken
    @RequestMapping(value = "/do/park",method = RequestMethod.POST)
    public Result doPark(@RequestBody CarLocation carLocation){
        carLocation.setUserId(getUserId());
        parkInfoService.doPark(carLocation);
        return SUCCESS();
    }

}
